package com.hu.zhcc.shiro.controller;

import com.github.pagehelper.PageInfo;
import com.hu.zhcc.shiro.entity.bo.CheckGroup;
import com.hu.zhcc.shiro.entity.bo.CheckHabitus;
import com.hu.zhcc.shiro.entity.bo.CheckItem;
import com.hu.zhcc.shiro.entity.bo.CheckResult;
import com.hu.zhcc.shiro.entity.dto.RouterDTO;
import com.hu.zhcc.shiro.entity.vo.CheckGroupVO;
import com.hu.zhcc.shiro.entity.vo.CheckHabitusVO;
import com.hu.zhcc.shiro.entity.vo.RouterDetailVO;
import com.hu.zhcc.shiro.service.CheckGroupService;
import com.hu.zhcc.shiro.service.CheckHabitusService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 体质评估
 */

@RestController
@CrossOrigin
@RequestMapping("/checkhabitus")
public class CheckHabitusController {
    @Autowired
    private CheckHabitusService checkHabitusService;

    @GetMapping("")
    @ResponseBody
    public PageInfo<CheckHabitus> homeCheckHabitus(CheckHabitusVO checkHabitusVO){
        PageInfo<CheckHabitus> checkHabitusPageInfo = checkHabitusService.pageQuery(checkHabitusVO);
        return checkHabitusPageInfo;
    }

    @PostMapping("")
    public ResponseEntity<?> saveCheckitem(@RequestBody CheckHabitus checkHabitus) {
        return checkHabitusService.AddHabitus(checkHabitus) ? ResponseEntity.noContent().build() :
                ResponseEntity.notFound().build();
    }
    @DeleteMapping("/{id}")
    public ResponseEntity<?> removeCheckHabitus(@PathVariable("id") Short id) {
        return checkHabitusService.removeHabitus(id) ? ResponseEntity.noContent().build() :
                ResponseEntity.notFound().build();
    }

    @PutMapping("/{id}")
    public ResponseEntity<Integer> updateRouter(@PathVariable("id") int id, @RequestBody CheckHabitus checkHabitus) {
        return checkHabitusService.updateHabitus(checkHabitus) ? ResponseEntity.noContent().build() :
                ResponseEntity.notFound().build();
    }
}
